<template>
  <div class="SecondedShenq">
    <div class="Title">
      <div class="blue"></div>
      <span class="title">人员借调</span>
      <el-button
        class="right-box"
        type="info"
        icon="el-icon-back"
        onclick="window.history.go(-1)"
      >返回</el-button>
    </div>
    <div class="secondedShenq">
      <div class="secondeList">
        <!-- <template> -->
        <el-table :data="tableData" height="250" border style="width: 100%">
          <el-table-column prop label="借调车间">
            <template slot-scope="scope">
              <el-select v-model="scope.row.name" placeholder="请选择">
                <el-option
                  v-for="item in selectDataweixiu"
                  :value="item.no"
                  :label="item.name"
                  :key="item.name"
                ></el-option>
              </el-select>
            </template>
          </el-table-column>
          <el-table-column prop="name" label="借调岗位">
            <template slot-scope="scope">
              <el-select v-model="scope.row.name" placeholder="请选择">
                <el-option
                  v-for="item in selectDatagangwei"
                  :value="item.no"
                  :label="item.name"
                  :key="item.name"
                ></el-option>
              </el-select>
            </template>
          </el-table-column>
          <el-table-column prop="address" label="借调人数">
            <template slot-scope="scope">
              <el-input type="textarea" v-model="scope.row.renshu"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="name" label="到岗时间">
            <template slot-scope="scope">
              <el-input type="textarea" v-model="scope.row.dao"></el-input>
            </template>
          </el-table-column>
          <el-table-column prop="name" label="归还时间">
            <template slot-scope="scope">
              <el-input type="textarea" v-model="scope.row.gui"></el-input>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <div class="empphone_Btn">
        <el-form ref="form" :model="form" label-width="80px">
          <el-form-item>
            <el-button type="primary" @click="secondSure">确认</el-button>
            <el-button type="info" onclick="window.history.go(-1)">返回</el-button>
          </el-form-item>
        </el-form>
      </div>
    </div>
  </div>
</template>
       
<script>
import axios from "axios";
export default {
  data() {
    return {
      tableData: [{ text: 1 }],
      form: {},
      selectDataweixiu: [],
      selectDatagangwei: [],
      value: ""
    };
  },
  created() {
    this.getoption();
    this.getgangwei();
  },
  methods: {
    // 借调车间
    getoption() {
      axios(
        "/apis/CommondMethod.asmx/DropDown?index=1&member=" + "借调车间"
      ).then(({ data }) => {
        var datas = this.$x2js.xml2js(data);
        console.log(datas);
        var optionlist = JSON.parse(datas.string.__text);
        // console.log("optionlist");
        // console.log(optionlist);
        this.selectDataweixiu = optionlist;
      });
    },
    // 借调岗位
    getgangwei() {
      axios(
        "/apis/CommondMethod.asmx/DropDown?index=1&member=" + "借调岗位"
      ).then(({ data }) => {
        var datas = this.$x2js.xml2js(data);
        var gangweilist = JSON.parse(datas.string.__text);
        this.selectDatagangwei = gangweilist;
      });
    },
    secondSure() {
      var obj = {
        room: "",
        chejian: this.tableData[0].name,
        gangwei: this.tableData[0].name,
        renshu: this.tableData[0].renshu,
        dao: this.tableData[0].dao,
        gui: this.tableData[0].gui
      };
      var objs = JSON.stringify(obj);
      axios(
        "/apis/ProductionManagement.asmx/Save?index=30" +
          "&jsondata=" +
          objs
      ).then(({ data }) => {
        var datas = this.$x2js.xml2js(data);
        console.log(datas)
        if (datas.string.__text == "SUCCESS") {
          this.$message.success("审核通过!");
          window.history.go(-1);
        } else {
          this.$message.error(datas.string.__text);
        }
      });
    }
  }
};
</script>

<style lang="scss" scoped>
@import "@/assets/scss/base.scss";
.SecondedShenq {
  width: 98%;
  height: 700px;
  //   border: 1px solid #000;
}
.Title {
  width: 99%;
  height: 35px;
  margin-top: 10px;
}
.blue {
  width: 5px;
  height: 20px;
  background-color: $red;
  margin-left: 20px;
  margin-top: 5px;
  float: left;
}
.title {
  margin-left: 10px;
  line-height: 35px;
}
.secondedShenq {
  width: 99%;
  height: 90%;
  margin-top: 10px;
  margin-left: 15px;
  border: 1px solid $linecolor;
  background-color: $white;
}
.secondeList {
  width: 65%;
  margin: 0 auto;
  margin-top: 40px;
  border: 2px solid $linecolor;
}
.empphone_Btn {
  width: 99%;
  height: 100px;
  margin-top: 30px;
  text-align: center;
  // border: 1px solid #000;
}
.right-box {
  float: right;
  margin-right: 2%;
  border-radius: 5px;
}
</style>
